package org.hyl.javabase;

import java.text.SimpleDateFormat;
import java.util.Date;

public class p201707003 {
	
  static p201707003 a=new p201707003();
  
  public static void main(String[] arg){
	  
	//  a. fileread1();
	  String f=a.fun6("zdo :%tY-%tM-%tD��",new Date( ));
	  System.out.println(f);
  }
  public void fun1(){
	  
	  String b=" hello";
	  b += "you";
	  b = b.concat(" cccc");
	//  System.out.println(b);
	  if (b.endsWith("ccq1"))
		  System.out.println("ok cc");
	  
	  
  }
  public void fun2(){
	  String b="hello"; //[5] {'h','e','l','l','0'}
	  String c=b;
	  if (b=="hello")
		  System.out.println("ok0");
	  if (b.equals("hello"))
		  System.out.println("ok1");
	  
	 // String c=new String("hello");
	  if (b==c)
		  System.out.println("ok2");
	  if (b.equals(c))
		  System.out.println("ok3");

	  
  }
  
  public void fun3(){
	  
	  objtest o=new objtest();
	  o.fun1();
	  
  }
  
  class objtest{
	  public int n=9;
	  public void fun1(){
		  
	  }
  }
  
  public void fun4(){
	  
	  
	  int i=9;
	  try{
		 int b= i/0;
		  System.out.println(b);
		  
		  
	  }catch(Exception e){
		  
		  System.out.println("err");
	  }
	  
	  
  }
  
  public void fun5(){
	  char[] b=new char[100]; //stringbuild stringbuffer
	  char[] c={'a','c','c','o','n','t'};  //string
	 // c=new char[9];
	 // c={'a','c','c','o','n','t','y','o','u'};
	  b[0]='a';
	  b[1]='c';
	  b[2]='c';
	  b[3]='o';
	  b[4]='n';
	  b[5]='t';
	 
	  
	  
	  b[6]='y';
	  b[7]='o';
	  b[8]='u';
	
	  System.out.println(b.length);
	  System.out.println(c.length);
  }
  public String fun6(String sformat,Date dat){
	  SimpleDateFormat year=new SimpleDateFormat ("y");
	  SimpleDateFormat month=new SimpleDateFormat ("M");
	  SimpleDateFormat day=new SimpleDateFormat ("d");
	  String stry=year.format(dat);
	  String strm=month.format(dat);
	  String strd=day.format(dat);
	  sformat=sformat.replace("%tY", stry);
	  sformat=sformat.replace("%tM", strm);
	  sformat=sformat.replace("%tD", strd);
	  return sformat;
  }
  // System.out.printf("%1$s %2$tB %2$td, %2$tY",   "Due date:", date);
 
}
